package com.itheima.spring_boot_init;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
public class DemoController {

    @Value("${name}")
    private String name;
    @Value("${person.name}")
    private String name1;
    @Value("${address[1]}")
    private String address;
    @Value("${ms2}")
    private String ms1;

    @Autowired
    private Environment environment;

    @Autowired
    private Person person;


    @RequestMapping("/demo1")
    public String demo1(){

        System.out.println(name);
        System.out.println(name1);
        System.out.println(address);
        System.out.println(ms1);

        System.out.println("----------------");
        System.out.println(environment.getProperty("ms2"));
        System.out.println(environment.getProperty("name"));

        System.out.println("----------------");

        System.out.println(person);
        String[] address = person.getAddress();
        for (String s : address) {
            System.out.println(s);
        }

        return "ffff";
    }
}
